<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<title>IP白名单</title>
	<link rel="shortcut icon" type="image/ico" href="${basePath}/favicon.ico?v=1"/>
	<link rel="stylesheet" type="text/css" href="${basePath}/css/style-1.css" />
	<link rel="stylesheet" type="text/css" href="${basePath}/css/style_2_common.css" />>
	<script type="text/javascript" src="${basePath}/js/jquery-1.8.3.min.js"></script>
	<link rel="stylesheet" type="text/css" href="${basePath}/js/layer/skin/layer.css" />
	<script type="text/javascript" src="${basePath}/js/layer/layer.m.js"></script>
	<style>.imgSize{width:100px; height:50px;}</style>
</head>
<body id="nv_member" class="pg_CURMODULE">
<#assign current="menu_ipwhite">
	<div id="wp" class="wp">
		<#include "/include/header.html"/>
		<div class="contentmanage">
			<div class="developer">
				<div class="tableContent">
				<#include "/include/left.html"/>
				<#include "/include/wxtop.html"/>
				<div class="content">
					<div class="cLine">
						<div class="pageNavigator">
							<a href='${basePath}/admin/ipwhite/edit' class='btnGrayS vm bigbtn'><img src="${basePath}/images/text.png" class="vm" />新增</a>
							<div class="right">
								<form action="${basePath}/admin/ipwhite/index" method="post" id="form_pagination">
								<input class="px" name="description" placeholder="输入描述检索" value="${description!}" maxlength="100"/>
								<input type="submit" value="搜索" class='btnGreen'/>
								</form>	
							</div>
						</div>
						<div class="clr"></div>
					</div>
         			<div class="msgWrap">
	           			<table class="ListProduct" border="0" cellSpacing="0" cellPadding="0" width="100%">
		           			<thead>
		           				<tr valign="top">
		           					<th class="">起始IP</th>
		           					<th class="">结束IP</th>
		           					<th class="">状态</th>
		           					<th class="">描述</th>
		           					<th class="">操作</th>
		        				</tr>
		       				</thead>
		       				<tbody>
		       					<#if page?exists>
		       					<#list page.recordList as bean>
								<tr>
		  							<td>${bean.beginIp!}</td>
		  							<td>${bean.endIp!}</td>
		  							<td id="vt-${bean.id!}" flag="${bean.isValid!}"><#if bean.isValid==0>停用<#else>启用</#if></td>
		  							<td>${bean.description!}</td>
		  							<td class="norightborder">
		  								<a href="${basePath}/admin/ipwhite/edit?id=${bean.id!}" >编辑</a>
		  								<a href="javascript:void(0);" onclick="delItem('${bean.id!}');">删除</a>
		  								<a href="javascript:void(0);" onclick="setValid('${bean.id!}');" id="va-${bean.id!}"><#if bean.isValid==0>启用<#else>停用</#if></a>
		  							</td>
								</tr>
								</#list>
								</#if>
							</tbody>
						</table>
					</div>
			<#assign formUrl="${basePath}/admin/ipwhite/index?">
			<#include "/include/pagination.html">
		</div>
		<div class="clr"></div>
	</div></div></div>
<!--底部--></div>
<#include "/include/footer.html"/>
<script type="text/javascript">
function delItem(id){
	layer.confirm("确定要删除吗？"
			,{icon: 4, title:'确认信息'}
	,function(index){
		layer.close(index);
		window.location.href="${basePath}/admin/ipwhite/del?id="+id;
	},function(index){
		layer.msg("您取消了删除操作");
		layer.close(index);
	});
}

//启用 停用
function setValid(id){
	var msg,isValid,validFlag,vtState,vaState;
	var vtid="vt-"+id,vaid="va-"+id;
	
	validFlag = $("#"+vtid).attr("flag");
	if(!validFlag||validFlag==""){
		layer.alert("无效数据，刷新重试",{icon:0});
		return;
	}

	if(validFlag==0){
		msg="您确定要启用吗?";
		isValid = 1;
		vtState = "启用";
		vaState = "停用";
	}else{
		msg="您确定要停用吗?";
		isValid = 0;
		vtState = "停用";
		vaState = "启用";
	}
	
	layer.confirm(msg,{icon: 4, title:'确认信息'},
		function(index){
			layer.close(index);
			$.ajax({
	             type: "POST",
	             url: "${basePath}/admin/ipwhite/setValid",
	             data: {isValid:isValid,id:id},
	             dataType: "json",
	             success: function(data){
	            	 if(data.success==true){
	            		 layer.msg("修改成功");
	            		 $("#"+vaid).text(vaState);
	            		 $("#"+vtid).text(vtState);
	            		 $("#"+vtid).attr("flag",isValid);
	            	 }else{
	            		 layer.msg("修改失败");
	            	 }
	             }
	         });
		},function(index){
			layer.msg("您取消了操作");
			layer.close(index);
		});
}
</script>
</body>
</html>